import 'package:flutter_learn_vi/src/net/dio_utils.dart';
import 'package:get/get.dart';

import '../../../bean/bean_study_data.dart';

class MyStudyDataDetailsController extends GetxController {
  StudyDataBean studyDataBean;

  bool _isLoading = true;

  Future<bool> requestCategoryList(int id) async {
    Map<String, dynamic> map = Map();
    ResponseInfo responseInfo = await DioUtils.instance.getRequest(
        url: HttpHelper.materialInfoUrl + "$id", queryParameters: map);
    _isLoading = false;
    if (responseInfo.success) {
      studyDataBean = StudyDataBean.fromMap(responseInfo.data);
    } else {
      studyDataBean = null;
    }
    update(["details"]);
    return true;
  }

  bool get isLoading => _isLoading;

  Future<bool> onPullRefresh(int id) async {
    return requestCategoryList(id);
  }

  Future<bool> onClickItemRefresh(int id) {
    _isLoading = true;
    update(["details"]);
    return requestCategoryList(id);
  }
}
